package ${packageDir}.controller;

import ${packageDir}.model.${className};
import com.gomyb.common.base.BaseController;
import com.gomyb.common.base.BaseService;
import com.gomyb.common.page.PageResult;
import com.gomyb.result.Result;
import lombok.extern.slf4j.Slf4j;
import com.gomyb.admin.common.annotation.HandleLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ${author}
 * ${time}
 */
@RestController
@Slf4j
@RequestMapping(value = "/${classNameLow}", name = "${discribe}")
public class ${className}Controller extends BaseController<${className}, Long> {

    @Override
    @Autowired
    public void setService(BaseService<${className}, Long> service) {
        super.service = service;
    }

    @PostMapping(value = "/see/{id}", name = "查看")
    @HandleLog(value = "查看${discribe}")
    public Result<${className}> see(@PathVariable("id") Long id) {
        return super.get(id);
    }

    @PostMapping(value = "/add", name = "添加")
    @HandleLog(value = "添加${discribe}")
    public Result add(${className} ${classNameLow}) {
        return super.save(${classNameLow});
    }

    @PostMapping(value = "/modify", name = "修改")
    @HandleLog(value = "修改${discribe}")
    public Result modify(${className} ${classNameLow}) {
        return super.update(${classNameLow});
    }

    @PostMapping(value = "/list", name = "列表")
    public PageResult<${className}> list(HttpServletRequest request) {
        return super.findPage(request);
    }

    @PostMapping(value = "/remove", name = "删除")
    @HandleLog(value = "删除${discribe}")
    public Result remove(String ids) {
        return super.deleteAll(ids);
    }

}
